//
//  AreaDAO.m
//  ItboyeLibrary
//
//  Created by hebidu on 15/9/24.
//  Copyright © 2015年 Boye. All rights reserved.
//

#import "AreaDAO.h"
#import "AreaEntity.h"

@implementation AreaDAO


-(id) queryByCityID:(NSString *)cityID{
    
    NSString * path = [[NSBundle mainBundle] pathForResource: SQLLITE3_DATABASE_NAME  ofType:@"db"];
    
    BOOL result = [[SqliteHelper sharedInstance] openDB:path];
    
    NSString *queryStr = @"select id,areaID,area,father from common_area where father = ?";
    if (result) {
        
        FMDatabase * database =    [SqliteHelper sharedInstance].database;
        FMResultSet * resultSet =  [database executeQuery:queryStr withArgumentsInArray:[NSArray arrayWithObject:cityID]];
        NSMutableArray * resultArray = [[NSMutableArray alloc]init];
        while ([resultSet next]) {
            AreaEntity * entity = [[AreaEntity alloc]init];
            entity.area = [resultSet stringForColumn:@"area"];
            entity.areaID = [resultSet stringForColumn:@"areaID"];
            entity.father = [resultSet stringForColumn:@"father"];
            entity.id= [resultSet intForColumn:@"id"] ;
            [resultArray addObject:entity];
        }
        [[SqliteHelper sharedInstance] closeDB];
        return resultArray;
    }
    return nil;
    
    
}


/**
 *  查询
 *
 *  @param withArgumentsInArray 参数
 *
 *  @return 数组
 */
-(id) query:(NSArray *)arguments{
    return nil;
}
/**
 *  查询
 *
 *  @param withArgumentsInArray 参数
 *
 *  @return 数组
 */
-(id) add:(id)obj{
    return nil;
}


/**
 *  删除
 *
 */
-(id) delete:(id)obj{
    return nil;
}


/**
 *  更新
 *
 */
-(id) update: (id)obj{
    return nil;
}


@end
